<template>
	<view class="home-container">
		<NavBar></NavBar>
		<TabBar :currentTabBarIndex="currentTabBarIndex" @changeTabBarIndex="changeTabBarIndex" :tabBarList="tabBarList"></TabBar>
		<ArticleList :currentTabBarIndex="currentTabBarIndex" @changeTabBarIndexBySwiper="changeTabBarIndexBySwiper" :tabBarList="tabBarList" class="list-container"></ArticleList>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				tabBarList: [],
				currentTabBarIndex: 0
			}
		},
		onLoad() {
			this.getLabelList()
		},
		methods: {
			async getLabelList() {
				const res = await this.$http.getLabelList()
				if (res.code === 0) {
					this.tabBarList = res.data
				}
			},
			/**
			 * tabBar 点击事件改变当前选中的 tabBar
			 * @param {Object} index
			 */
			changeTabBarIndex(index) {
				this.currentTabBarIndex = index
			},
			changeTabBarIndexBySwiper(index) {
				this.currentTabBarIndex = Number(index)
			}
		}
	}
</script>

<style lang="scss">
	page {
		display: flex;
		height: 100%;
	}
	.home-container {
		@include flex(flex-start, column)
		flex: 1;
		overflow: hidden;
		box-sizing: border-box;
		align-items: inherit;
	}
	.list-container {
		flex: 1;
		box-sizing: border-box;
	}
</style>
